<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>书籍购物车</title>
  <link type="text/css" href="style.css"/>
</head>
<style>
  table, table tr td {
    border: 1px solid #000;
    text-align: center;
    border-collapse: collapse;
  }

</style>
<body>
<div id="app">
  <div v-if="books.length">
    <table>
      <thead>
      <td></td>
      <td>书籍名称</td>
      <td>出版日期</td>
      <td>价格</td>
      <td>购买数量</td>
      <td>操作</td>
      </thead>
      <tbody>
      <tr v-for="(item,index) in books">
        <td>{{item.id}}</td>
        <td>{{item.name}}</td>
        <td>{{item.date}}</td>
        <td>{{item.price | showPrice}}</td>
        <td>
          <!--:disabled="item.count<=1"：当disabled小于等于1的时候，这个按钮就不能用了-->
          <button @click="decrement(index)" :disabled="item.count<=1">-</button>
          {{item.count}}
          <button @click="increment(index)">+</button>
        </td>
        <td>
          <button @click="clear(index)">移除</button>
        </td>
      </tr>
      </tbody>
    </table>
    <h2>总价格：{{totalPrice | showPrice}}</h2>
  </div>
  <div v-else>
    <h2>购物车为空</h2>
  </div>
</div>

<script src="../js/vue.js"></script>
<script src="main.js"></script>
</body>
</html>
